/*
 * @Author: lixiaoming xiaoming.li@cy-tech.net
 * @Date: 2024-10-16 08:49:36
 * @LastEditors: lixiaoming xiaoming.li@cy-tech.net
 * @LastEditTime: 2024-11-29 09:48:40
 * @FilePath: /web3-app/hardhat/ignition/modules/Lock.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
// This setup uses Hardhat Ignition to manage smart contract deployments.
// Learn more about it at https://hardhat.org/ignition
const { buildModule } = require("@nomicfoundation/hardhat-ignition/modules");
const { ethers } = require("hardhat");
const JAN_1ST_2030 = 1893456000;
const ONE_GWEI = 1_000_000_000n;
const amountToMint = "1000000"; // 1 million tokens

// Convert this amount to the smallest unit (assuming the token has 18 decimals)
const decimals = 18; // Typical ERC20 has 18 decimals
const amountInSmallestUnit = ethers.parseUnits(amountToMint, decimals);
// console.log(amountInSmallestUnit,'amountInSmallestUnit')
module.exports = buildModule("LockModule", (m) => {
  const unlockTime = m.getParameter("unlockTime", JAN_1ST_2030);
  const lockedAmount = m.getParameter("lockedAmount", ONE_GWEI);
  const initialSupply = m.getParameter("initialSupply", amountInSmallestUnit);
  const initialGreeting = m.getParameter("initialGreeting", "Hello, World!");
  const faucetAmount = m.getParameter("faucetAmount", ethers.parseEther("0.1")); // 0.1 ETH per request

  const lock = m.contract("Lock", [unlockTime], {
    value: lockedAmount,
  });
  const MyMint = m.contract("MyMint", [initialSupply]);
  const Airdrop = m.contract("Airdrop");
  const SendEth = m.contract("SendEth");
  const Voting = m.contract("Voting",[["Mark", "Mike", "Henry", "Rock"], 43200]);
  const IPFShashStorage = m.contract("IPFShashStorage");
  
  // 添加新合约的部署
  const VerifySignature = m.contract("VerifySignature");
  const Greeting = m.contract("Greeting", [initialGreeting]);
  const Faucet = m.contract("Faucet", [faucetAmount]);

  return { 
    lock,
    MyMint,
    Airdrop,
    SendEth,
    Voting,
    IPFShashStorage,
    VerifySignature,
    Greeting,
    Faucet
  };
});
